<template>
  <div class="app-container">
    <div class="filter-container">
      <el-input
        v-model="zdInsuranceProducts.zdAutomaticPlanName"
        placeholder="自动计划名称"
        style="width: 150px;margin-left: 45px;"
        class="filter-item"
        @keyup.enter.native="getZdPlan"
      />
      <el-input
        v-model="zdInsuranceProducts.mechanismName"
        placeholder="机构名称"
        style="width: 150px;"
        class="filter-item"
        @keyup.enter.native="getZdPlan"
      />
      <el-input
        v-model="zdInsuranceProducts.planName"
        placeholder="计划名称"
        style="width: 150px;"
        class="filter-item"
        @keyup.enter.native="getZdPlan"
      />
      <el-select
        v-model="zdInsuranceProducts.enableStatus"
        clearable
        placeholder="状态"
        style="width: 200px;"
        class="filter-item"
      >
        <el-option label="全部">全部</el-option>
        <el-option :value="0" label="启用">启用</el-option>
        <el-option :value="1" label="未启用">未启用</el-option>
      </el-select>
      <el-button
        class="filter-item"
        style="margin-left: 45px;"
        type="primary"
        icon="el-icon-search"
        @click="getZdPlan"
      >
        搜索
      </el-button>
      <br />
      <el-button
        class="filter-item"
        style="margin-left: 45px;"
        type="success"
        icon="el-icon-plus"
        @click="handleCreate"
      >
        新增自动推送计划
      </el-button>
      <el-button
        class="filter-item"
        style="margin-left: 45px;"
        type="primary"
        @click="editAll"
      >
        批量修改线索时间
      </el-button>
    </div>
    <el-table
      :data="tableData"
      border
      :row-key="bindRowkeys"
      ref="multipleTable1"
      style="width: 95%;margin:auto;margin-top:10px"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" :reserve-selection="true">
      </el-table-column>
      <el-table-column prop="automaticPlanName" label="自动计划名称">
      </el-table-column>
      <el-table-column prop="mechanismName" label="机构名称"> </el-table-column>
      <el-table-column prop="planName" label="计划名称"> </el-table-column>
      <el-table-column prop="createTime" label="创建时间"> </el-table-column>
      <el-table-column label="线索开始时间" width="300px" align="center">
        <template slot-scope="{ row }">
          {{ row.startTime }}~{{ row.endTime }}
        </template>
      </el-table-column>
      <el-table-column prop="intervals" label="间隔时间"> </el-table-column>
      <el-table-column prop="clueType" label="类型"> </el-table-column>
      <el-table-column prop="cityName" label="城市"> </el-table-column>
      <el-table-column
        label="启用状态"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="{ row }">
          <el-switch
            v-model="row.enableSwitch"
            active-text="开"
            inactive-text="关"
            active-color="#13ce66"
            inactive-color="#ff4949"
            @change="changeEnable(row)"
          />
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" width="380px">
        <template slot-scope="{ row }">
          <el-button
            type="primary"
            size="mini"
            @click="filterConfiguration(row)"
          >
            过滤器配置
          </el-button>
          <el-button type="primary" size="mini" @click="cityConfigure(row)">
            城市配置
          </el-button>
          <el-button type="success" size="mini" @click="handelEdit(row)">
            编辑
          </el-button>
          <el-button type="warning" size="mini" @click="handleDelete(row)">
            删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="zdInsuranceProducts.current"
      :limit.sync="zdInsuranceProducts.size"
      @pagination="getZdPlan"
    />

    <el-dialog :visible.sync="dialogVisible" :title="titleText">
      <el-form ref="planData" :model="zdLeadPush" label-width="150px">
        <el-form-item label="自动推送计划名称">
          <el-input v-model="zdLeadPush.automaticPlanName"></el-input>
        </el-form-item>
        <el-form-item label="选择推送机构">
          <el-select
            v-model="release"
            clearable
            placeholder="请选择"
            style="width: 200px;"
            class="filter-item"
            @change="changejigou"
            filterable
          >
            <el-option
              v-for="(item, index) in selectArr"
              :key="index"
              :value="item.mechanismName"
              :label="item.mechanismName"
              @click.native="handleChange1(item)"
            >
              {{ item.mechanismName }}
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="选择推送计划">
          <el-select
            v-model="planList"
            clearable
            placeholder="请选择"
            style="width: 200px;"
            class="filter-item"
          >
            <el-option
              v-for="(item, index) in planSelectArr"
              :key="index"
              :value="item.planName"
              :label="item.planName"
              @click.native="handleChange(item)"
            >
              {{ item.planName }}
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="线索开始时间">
          <el-date-picker
            v-model="times"
            class="filter-item"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            style="width: 250px;"
            type="datetimerange"
            value-format="yyyy-MM-dd HH:mm:ss"
          />
        </el-form-item>
        <div style="display:flex;align-items:center;">
          <el-form-item label="推送间隔时间" style="width:80%">
            <el-input v-model="zdLeadPush.intervals" type="number"></el-input>
          </el-form-item>
          <span style="font-size:16px;margin-left:50px;font-weight:600"
            >分钟/条</span
          >
        </div>
        <el-form-item label="线索类型">
          <el-checkbox-group v-model="clueType">
            <el-checkbox-button
              label="非时段"
              name="clueType"
            ></el-checkbox-button>
            <el-checkbox-button
              label="高质量"
              name="clueType"
            ></el-checkbox-button>
          </el-checkbox-group>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">
          取消
        </el-button>
        <el-button
          type="primary"
          @click="
            titleText === '新增自动推送计划' ? createData() : updateData()
          "
        >
          确认
        </el-button>
      </div>
    </el-dialog>
    <el-dialog :visible.sync="dialogVisibleUpdateTime" title="批量修改线索时间">
      <el-form label-width="150px">
        <el-form-item label="线索开始时间">
          <el-date-picker
            v-model="allTimes"
            class="filter-item"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            style="width: 250px;"
            type="datetimerange"
            :picker-options="pickerOptionsStart"
            value-format="yyyy-MM-dd HH:mm:ss"
          />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogVisibleUpdateTime = false">
          取消
        </el-button>
        <el-button type="primary" @click="updateTime">
          确认
        </el-button>
      </div>
    </el-dialog>
    <el-dialog :visible.sync="dialogVisible2" title="过滤器配置">
      <el-form :model="filterQuery" label-width="150px">
        <el-form-item label="借款额度">
          <el-checkbox-group v-model="filterQuery.newLoanLimit">
            <el-checkbox-button
              label="5万"
              name="newLoanLimit"
            ></el-checkbox-button>
            <el-checkbox-button
              label="10万"
              name="newLoanLimit"
            ></el-checkbox-button>
            <el-checkbox-button
              label="20万"
              name="newLoanLimit"
            ></el-checkbox-button>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item label="芝麻分范围">
          <el-checkbox-group v-model="filterQuery.newSesameSeed">
            <el-checkbox-button
              label="600分以下"
              name="newSesameSeed"
            ></el-checkbox-button>
            <el-checkbox-button
              label="600到649分"
              name="newSesameSeed"
            ></el-checkbox-button>
            <el-checkbox-button
              label="650到699分"
              name="newSesameSeed"
            ></el-checkbox-button>
            <el-checkbox-button
              label="700分以上"
              name="newSesameSeed"
            ></el-checkbox-button>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item label="逾期情况">
          <el-checkbox-group v-model="filterQuery.overdueSituation">
            <el-checkbox-button
              label="当前有逾期"
              name="overdueSituation"
            ></el-checkbox-button>
            <el-checkbox-button
              label="无逾期"
              name="overdueSituation"
            ></el-checkbox-button>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item label="用户年龄">
          <el-input
            placeholder="最小年龄"
            type="number"
            style="width:150px"
            v-model="filterQuery.minAge"
          ></el-input
          >&nbsp;&nbsp; 到&nbsp;&nbsp;
          <el-input
            type="number"
            placeholder="最大年龄"
            style="width:200px"
            v-model="filterQuery.maxAge"
          ></el-input>
        </el-form-item>
        <el-form-item label="签署协议">
          <el-checkbox-group v-model="filterQuery.isAgreement">
            <el-checkbox-button
              label="已签署"
              name="isAgreement"
            ></el-checkbox-button>
            <el-checkbox-button
              label="未签署"
              name="isAgreement"
            ></el-checkbox-button>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item label="满足条件">
          <el-radio-group v-model="meetConditions" size="medium">
            <el-radio border label="全部不匹配"></el-radio>
            <el-radio border label="满足全部条件"></el-radio>
            <el-radio border label="满足其一条件"></el-radio>
          </el-radio-group>
        </el-form-item>
        <div>
          <div style="margin-left:80px;margin-bottom:20px">
            说明：<br />
            1. 全部不匹配：不进行匹配，什么用户信息都要<br />
            2. 满足全部条件：满足所有所选条件，才会匹配成功<br />
            3. 满足其一条件：满足多项资产的一个就匹配成功（仅可选择个人资产）<br />
          </div>
        </div>
        <el-form-item label="学历">
          <el-checkbox-group v-model="filterQuery.education">
            <el-checkbox-button
              label="本科及以上"
              name="education"
            ></el-checkbox-button>
            <el-checkbox-button
              label="本科以下"
              name="education"
            ></el-checkbox-button>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item label="职业">
          <el-checkbox-group v-model="filterQuery.occupation">
            <el-checkbox-button
              label="公务员/国企"
              name="occupation"
            ></el-checkbox-button>
            <el-checkbox-button
              label="私营企业主"
              name="occupation"
            ></el-checkbox-button>
            <el-checkbox-button
              label="上班族"
              name="occupation"
            ></el-checkbox-button>
            <el-checkbox-button
              label="自由职业"
              name="occupation"
            ></el-checkbox-button>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item label="本地社保">
          <el-checkbox-group v-model="filterQuery.socialSecurity">
            <el-checkbox-button
              label="无本地社保"
              name="socialSecurity"
            ></el-checkbox-button>
            <el-checkbox-button
              label="6个月以下"
              name="socialSecurity"
            ></el-checkbox-button>
            <el-checkbox-button
              label="6个月以上"
              name="socialSecurity"
            ></el-checkbox-button>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item label="本地公积金">
          <el-checkbox-group v-model="filterQuery.accumulation">
            <el-checkbox-button
              label="无本地公积金"
              name="accumulation"
            ></el-checkbox-button>
            <el-checkbox-button
              label="6个月以下"
              name="accumulation"
            ></el-checkbox-button>
            <el-checkbox-button
              label="6个月以上"
              name="accumulation"
            ></el-checkbox-button>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item label="投保信息">
          <el-checkbox-group v-model="filterQuery.insurance">
            <el-checkbox-button
              label="有保险"
              name="insurance"
            ></el-checkbox-button>
            <el-checkbox-button
              label="无保险"
              name="insurance"
            ></el-checkbox-button>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item label="车产信息">
          <el-checkbox-group v-model="filterQuery.car">
            <el-checkbox-button label="有车" name="car"></el-checkbox-button>
            <el-checkbox-button label="无车" name="car"></el-checkbox-button>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item label="房产信息">
          <el-checkbox-group v-model="filterQuery.house">
            <el-checkbox-button label="有房" name="house"></el-checkbox-button>
            <el-checkbox-button label="无房" name="house"></el-checkbox-button>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item label="信用卡额度">
          <el-checkbox-group v-model="filterQuery.creditCard">
            <el-checkbox-button
              label="有信用卡"
              name="creditCard"
            ></el-checkbox-button>
            <el-checkbox-button
              label="无信用卡"
              name="creditCard"
            ></el-checkbox-button>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item label="花呗额度">
          <el-checkbox-group v-model="filterQuery.huabei">
            <el-checkbox-button
              label="有花呗"
              name="huabei"
            ></el-checkbox-button>
            <el-checkbox-button
              label="无花呗"
              name="huabei"
            ></el-checkbox-button>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item label="白条额度">
          <el-checkbox-group v-model="filterQuery.whiteStripe">
            <el-checkbox-button
              label="有白条"
              name="whiteStripe"
            ></el-checkbox-button>
            <el-checkbox-button
              label="无白条"
              name="whiteStripe"
            ></el-checkbox-button>
          </el-checkbox-group>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible2 = false">
          取消
        </el-button>
        <el-button type="primary" @click="filterSubmit()">
          确认
        </el-button>
      </div>
    </el-dialog>
    <el-dialog
      :visible.sync="dialogVisible3"
      title="城市配置"
      :before-close="cityClose"
    >
      <div style="display:flex;align-items:center;">
        <div style="font-weight:600;width:50px;margin-left:100px">城市</div>
        <div>
          <el-input
            v-model="zdAdvertisingPlanDTO.cityName"
            placeholder="输入城市名称"
            @keyup.enter.native="searchCity"
          ></el-input>
        </div>
        <el-button style="margin-left:20px" @click="searchCity">搜索</el-button>
      </div>
      <el-table
        ref="multipleTable"
        v-loading="loading2"
        :data="citys"
        :row-key="bindRowkeys"
        style="width: 60%;margin-left:100px;margin-top:20px"
        @selection-change="handleSelectionCityChange"
      >
        <el-table-column
          type="selection"
          width="55"
          :reserve-selection="true"
        />
        <el-table-column prop="cityName" label="城市名称" />
        <el-table-column prop="price" label="单价" />
      </el-table>
      <pagination
        v-show="total2 > 0"
        :total="total2"
        :page.sync="zdAdvertisingPlanDTO.current"
        :limit.sync="zdAdvertisingPlanDTO.size"
        @pagination="searchCity"
      />
      <div slot="footer" class="dialog-footer">
        <el-button @click="cityClose()">
          取消
        </el-button>
        <el-button type="primary" @click="citySubmit()">
          确认
        </el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  getZdPlan,
  getMechanism,
  addPromotioPlan,
  deletePlan,
  planList,
  openOrClose,
  updatePromotioPlan,
  channelConfigurationPlan,
  findCitys,
  updateCity,
  updateAll
} from '@/api/advertising';
import Pagination from '@/components/Pagination';
export default {
  components: { Pagination },
  data() {
    return {
      pickerOptionsStart: {
        // 时间不能大于当前时间
        disabledDate: time => {
          return time.getTime() > Date.now();
        }
      },
      zdInsuranceProducts: {
        current: 1,
        size: 10,
        zdAutomaticPlanName: '',
        mechanismName: '',
        planName: '',
        enableStatus: null
      },
      tableData: [],
      total: 0,
      dialogVisible: false,
      dialogVisible1: false,
      zdLeadPush: {
        automaticPlanName: '',
        mechanismId: '',
        mechanismName: '',
        mechanismType: '',
        planId: '',
        planName: '',
        startTime: '',
        endTime: '',
        intervals: '',
        clueType: '',
        id: null
      },
      release: '',
      clueType: [],
      planQuery: {
        mechanismId: '',
        type: ''
      },
      planList: [],
      selectArr: '',
      planSelectArr: [],
      selectValue: {},
      times: [],
      allTimes: [],
      zdAdvertisingPlanDTO: {
        current: 1,
        size: 10,
        planId: '',
        provinceName: '',
        cityName: ''
      },
      citys: [],
      total2: 0,
      titleText: '',
      dialogVisible2: false,
      meetConditions: '',
      filterQuery: {
        newLoanLimit: [],
        newSesameSeed: [],
        overdueSituation: [],
        isAgreement: [],
        education: [],
        occupation: [],
        socialSecurity: [],
        accumulation: [],
        insurance: [],
        car: [],
        house: [],
        creditCard: [],
        huabei: [],
        whiteStripe: [],
        id: null,
        minAge: null,
        maxAge: null
      },
      dialogVisible3: false,
      cityQuery: {
        zdAutomaticPlanId: null,
        list: []
      },
      cityNames: [],
      multipleSelection: [],
      dialogVisibleUpdateTime: false
    };
  },
  created() {
    this.getZdPlan();
  },
  watch: {
    citys(val) {
      this.$nextTick(() => {
        val.forEach(item => {
          if (this.cityNames) {
            this.cityNames.forEach(atem => {
              if (item.cityName == atem) {
                this.$refs.multipleTable.toggleRowSelection(item, true);
              }
            });
          }
        });
      });
    }
  },
  methods: {
    editAll() {
      this.dialogVisibleUpdateTime = true;
      this.allTimes = [];
    },
    updateTime() {
      var idArr = this.multipleSelection.map((item, index) => {
        return Object.assign({}, { id: item.id });
      });
      let start = this.allTimes[0];
      let end = this.allTimes[1];
      idArr.forEach((item, index) => {
        item.startTime = start;
        item.endTime = end;
      });
      if (this.allTimes.length == 0) {
        this.$notify({
          title: '更新失败',
          message: '请选择修改时间',
          type: 'fail',
          duration: 2000
        });
      } else if (idArr.length == 0) {
        this.$notify({
          title: '更新失败',
          message: '请选择修改计划',
          type: 'fail',
          duration: 2000
        });
      } else {
        updateAll(idArr).then(res => {
          if (res.data.code === 200) {
            this.$notify({
              title: '更新配置',
              message: '更新成功！',
              type: 'success',
              duration: 2000
            });
            this.dialogVisibleUpdateTime = false;
            this.$refs.multipleTable1.clearSelection();
            this.getZdPlan(this.zdInsuranceProducts);
          } else {
            this.$notify({
              title: '更新配置',
              message: res.data.msg,
              type: 'fail',
              duration: 2000
            });
          }
        });
      }
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    async getZdPlan() {
      const res = await getZdPlan(this.zdInsuranceProducts);
      this.tableData = res.data.data.records;
      this.total = res.data.data.total;
      this.tableData.forEach(e => {
        e.enableSwitch = e.enableStatus == 0;
      });
    },
    bindRowkeys(row) {
      return row.id;
    },
    changeEnable(row) {
      if (row.enableStatus === 1) {
        row.enableStatus = 0;
      } else {
        row.enableStatus = 1;
      }
      const memberCardDto = { enableStatus: row.enableStatus, id: row.id };
      openOrClose(memberCardDto).then(res => {
        if (res.data.code === 200) {
          this.$notify({
            title: '更新配置',
            message: '更新成功！',
            type: 'success',
            duration: 2000
          });
          this.getZdPlan(this.zdInsuranceProducts);
        } else {
          this.$notify({
            title: '更新配置',
            message: res.data.msg,
            type: 'fail',
            duration: 2000
          });
        }
      });
    },
    handleCreate() {
      this.titleText = '新增自动推送计划';
      this.zdLeadPush.automaticPlanName = '';
      this.release = '';
      this.planList = '';
      this.times = [];
      this.zdLeadPush.intervals = '';
      this.clueType = [];
      getMechanism().then(res => {
        if (res.data.code == 200) {
          this.selectArr = res.data.data;
          this.dialogVisible = true;
        } else {
          this.$notify({
            title: '业务提示',
            message: res.data.msg,
            type: 'fail',
            duration: 2000
          });
        }
      });
    },
    async handelEdit(row) {
      this.times = [];
      this.titleText = '编辑自动推送计划';
      const res = await getMechanism();
      this.dialogVisible = true;
      this.selectArr = res.data.data;
      this.zdLeadPush.automaticPlanName = row.automaticPlanName;
      this.release = row.mechanismName;
      this.planQuery.mechanismId = row.mechanismId;
      this.planQuery.type = row.mechanismType;
      const res1 = await planList(this.planQuery);
      this.planSelectArr = res1.data.data;
      this.planList = row.planName;
      this.zdLeadPush.planId = row.planId;
      this.zdLeadPush.intervals = row.intervals;
      if (row.clueType != null) {
        this.clueType = row.clueType.split(',');
      }
      this.times.push(row.startTime);
      this.times.push(row.endTime);
      this.zdLeadPush.id = row.id;
    },
    changejigou() {
      this.planList = '';
    },
    async handleChange1(item) {
      this.zdLeadPush.mechanismId = item.mechanismId;
      this.zdLeadPush.mechanismName = item.mechanismName;
      this.zdLeadPush.mechanismType = item.type;
      this.planQuery.mechanismId = item.mechanismId;
      this.planQuery.type = item.type;
      const res = await planList(this.planQuery);
      this.planSelectArr = res.data.data;
    },
    handleChange(item) {
      this.zdLeadPush.planId = item.id;
      this.zdLeadPush.planName = item.planName;
    },
    async cityConfigure(row) {
      this.cityNames = [];
      this.dialogVisible3 = true;
      this.cityQuery.zdAutomaticPlanId = row.id;
      this.zdAdvertisingPlanDTO.planId = row.planId;
      if (row.cityName) {
        this.cityNames = row.cityName.split(',');
      }
      const res = await findCitys(this.zdAdvertisingPlanDTO);
      this.citys = res.data.data.records;
      this.total2 = res.data.data.total;
    },
    async searchCity() {
      const res = await findCitys(this.zdAdvertisingPlanDTO);
      this.citys = res.data.data.records;
      this.total2 = res.data.data.total;
    },
    handleSelectionCityChange(val) {
      this.cityQuery.list = val;
    },
    filterConfiguration(row) {
      this.dialogVisible2 = true;
      this.filterQuery = {
        newLoanLimit: [],
        newSesameSeed: [],
        overdueSituation: [],
        isAgreement: [],
        education: [],
        occupation: [],
        socialSecurity: [],
        accumulation: [],
        insurance: [],
        car: [],
        house: [],
        creditCard: [],
        huabei: [],
        whiteStripe: [],
        id: null,
        minAge: null,
        maxAge: null
      };
      this.meetConditions = '';
      if (row.newLoanLimit) {
        this.filterQuery.newLoanLimit = row.newLoanLimit.split(',');
      }
      if (row.newSesameSeed) {
        this.filterQuery.newSesameSeed = row.newSesameSeed.split(',');
      }
      if (row.overdueSituation) {
        this.filterQuery.overdueSituation = row.overdueSituation.split(',');
      }
      if (row.isAgreement) {
        this.filterQuery.isAgreement = row.isAgreement.split(',');
      }
      if (row.meetConditions == 1) {
        this.meetConditions = '全部不匹配';
      }
      if (row.meetConditions == 2) {
        this.meetConditions = '满足全部条件';
      }
      if (row.meetConditions == 3) {
        this.meetConditions = '满足其一条件';
      }
      if (row.education) {
        this.filterQuery.education = row.education.split(',');
      }
      if (row.occupation) {
        this.filterQuery.occupation = row.occupation.split(',');
      }
      if (row.socialSecurity) {
        this.filterQuery.socialSecurity = row.socialSecurity.split(',');
      }
      if (row.accumulation) {
        this.filterQuery.accumulation = row.accumulation.split(',');
      }
      if (row.insurance) {
        this.filterQuery.insurance = row.insurance.split(',');
      }
      if (row.car) {
        this.filterQuery.car = row.car.split(',');
      }
      if (row.house) {
        this.filterQuery.house = row.house.split(',');
      }
      if (row.creditCard) {
        this.filterQuery.creditCard = row.creditCard.split(',');
      }
      if (row.huabei) {
        this.filterQuery.huabei = row.huabei.split(',');
      }
      if (row.whiteStripe) {
        this.filterQuery.whiteStripe = row.whiteStripe.split(',');
      }
      this.filterQuery.minAge = row.minAge;
      this.filterQuery.maxAge = row.maxAge;
      this.filterQuery.id = row.id;
    },
    cityClose() {
      this.dialogVisible3 = false;
      this.$refs.multipleTable.clearSelection();
    },
    citySubmit() {
      updateCity(this.cityQuery).then(res => {
        if (res.data.code === 200) {
          this.$notify({
            title: 'Success',
            message: '新增成功',
            type: 'success',
            duration: 2000
          });
          this.getZdPlan(this.zdInsuranceProducts);
        } else {
          this.$notify({
            title: 'fail',
            message: res.data.msg,
            type: 'fail',
            duration: 2000
          });
        }
        this.cityClose();
      });
    },
    filterSubmit() {
      for (let i in this.filterQuery) {
        if (this.filterQuery[i] != null) {
          this.filterQuery[i] = this.filterQuery[i].toString();
        }
      }
      if (this.meetConditions == '全部不匹配') {
        this.filterQuery.meetConditions = 1;
      }
      if (this.meetConditions == '满足全部条件') {
        this.filterQuery.meetConditions = 2;
      }
      if (this.meetConditions == '满足其一条件') {
        this.filterQuery.meetConditions = 3;
      }
      this.filterQuery.minAge = +this.filterQuery.minAge;
      this.filterQuery.maxAge = +this.filterQuery.maxAge;
      channelConfigurationPlan(this.filterQuery).then(res => {
        if (res.data.code === 200) {
          this.$notify({
            title: 'Success',
            message: '新增成功',
            type: 'success',
            duration: 2000
          });
          this.getZdPlan(this.zdInsuranceProducts);
        } else {
          this.$notify({
            title: 'fail',
            message: res.data.msg,
            type: 'fail',
            duration: 2000
          });
        }
        this.dialogVisible2 = false;
      });
    },
    // 弹窗确认
    createData() {
      this.zdLeadPush.endTime = this.times[1];
      this.zdLeadPush.startTime = this.times[0];
      this.zdLeadPush.intervals = +this.zdLeadPush.intervals;
      this.zdLeadPush.clueType = this.clueType.toString();
      addPromotioPlan(this.zdLeadPush).then(res => {
        if (res.data.code === 200) {
          this.$notify({
            title: 'Success',
            message: '新增成功',
            type: 'success',
            duration: 2000
          });
          this.getZdPlan(this.zdInsuranceProducts);
          this.dialogVisible = false;
        } else {
          this.$notify({
            title: 'fail',
            message: res.data.msg,
            type: 'fail',
            duration: 2000
          });
        }
      });
    },
    updateData() {
      this.zdLeadPush.mechanismId = this.planQuery.mechanismId;
      this.zdLeadPush.mechanismName = this.release;
      this.zdLeadPush.mechanismType = this.planQuery.type;
      this.zdLeadPush.planName = this.planList;
      this.zdLeadPush.endTime = this.times[1];
      this.zdLeadPush.startTime = this.times[0];
      this.zdLeadPush.intervals = +this.zdLeadPush.intervals;
      this.zdLeadPush.clueType = this.clueType.toString();
      updatePromotioPlan(this.zdLeadPush).then(res => {
        if (res.data.code === 200) {
          this.$notify({
            title: 'Success',
            message: '新增成功',
            type: 'success',
            duration: 2000
          });
          this.getZdPlan(this.zdInsuranceProducts);
          this.dialogVisible = false;
        } else {
          this.$notify({
            title: 'fail',
            message: res.data.msg,
            type: 'fail',
            duration: 2000
          });
        }
      });
    },
    handleDelete(row) {
      var that = this;
      this.$confirm('删除提示！', '确认删除吗？', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      }).then(() => {
        deletePlan({ id: row.id }).then(res => {
          if (res.data.code === 200) {
            that.$notify({
              title: 'Success',
              message: '删除成功',
              type: 'success',
              duration: 2000
            });
            this.getZdPlan(this.zdInsuranceProducts);
          } else {
            that.$notify({
              title: '错误',
              message: res.data.msg,
              type: 'fail',
              duration: 2000
            });
          }
        });
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.el-checkbox-button {
  margin-right: 50px;
  border: 1px solid rgb(218, 215, 215);
}
</style>
